<include file="Public/header"/>
<include file="Public/menu"/>
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		<div class="row">
			<ol class="breadcrumb">
				<li><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
				<li class="active">视频管理</li>
			</ol>
		</div><!--/.row-->
		
		<div class="row">
            <div class="col-lg-12">
                <div class="page-header" style="padding-bottom: 0px"></div>
            </div>
        </div><!--/.row-->
		
		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-heading">上传新视频</div>
					<div class="panel-body">
					<!-- <div id="pro" style="width: 600px;height: 20px;border:1px solid green;margin: 0 auto">
						<div id="bar" style="width: 0%;height: 100%;background-color: green">
							
						</div>
					</div> -->
					<div class="col-md-3"></div>
						<div class="col-md-6">
						
							
							
								<div class="form-group">
									<label>选择视频</label>
									<input type="file" name="filevideo">
									<!-- <textarea class="form-control" rows="6"></textarea> -->
								</div>
					         	<div class="form-group">

	    <button type="submit" class="btn btn-primary" onclick="savevideofile()">点击上传</button>
								<button type="reset" class="btn btn-default">重置</button>
								<div id='msg'></div>
								</div>
							</div>
							
 <script type="text/javascript">
 // function savevideofile(){
 // 		var vd = document.getElementsByTagName('input')[0].files[0];
 // 		var fd = null;
 // 			fd = new FormData();
 // 			fd.append('filevideo',vd);
 // 		var xhr = new XMLHttpRequest();
 // 			xhr.open('POST',"{:U('Video/uploadvdfile')}",false);
 // 			xhr.onreadystatechange = function(){
 //               document.getElementById('msg').innerHTML = this.responseText;
 // 			}
 // 			xhr.upload.onprogress = function(ev){
 //                      alert("00000");
 // 			}
 // 		// 	// xhr.upload.onprogress = function(ev){
 // 		// 	// 	console.log(ev);
 // 		// 	// 	// if(ev.lengthComputable){
 // 		// 	// 	// 	var res = ev.loaded/ev.total * 100;
 // 		// 	// 	// 	document.getElementById('bar').style.width = res + "%";
 // 		// 	// 	// }
 // 		// 	// }
 // 			xhr.send(fd);

 // 	}
 	function savevideofile(){
 		var vd = document.getElementsByTagName('input')[0].files[0];
 		//console.log(vd);
 		const sentlength = 2 * 1024 * 1024;
 		var sta = 0;
 		var end = sta + sentlength;
 		var blob = null;
 		var fd = null;
 		var xhr = null;
 		var sumsize = vd.size;
 		while (sta<sumsize) {
 			blob = vd.slice(sta, end);
 			fd = new FormData();
 			fd.append('filevideo',blob);
 		    xhr = new XMLHttpRequest();
 			xhr.open('POST',"{:U('Video/uploadvdfile')}",false);
 			xhr.upload.onprogress = function(){
 				alert("00000");
 			}
 			// xhr.onreadystatechange = function(){
    //            document.getElementById('msg').innerHTML = this.responseText;
 			// }
 			xhr.send(fd);
 			sta = end;
 			end = sta + sentlength;
 		}

 	}
 </script>

						
					</div>
				</div>
			</div><!-- /.col-->
		</div><!-- /.row -->
		
	</div><!--/.main-->

<include file="Public/footer"/>